package com.example.game.hff;

import java.awt.Graphics;
import java.awt.Image;

public class Crash implements Runnable{
	
	private int x, y;
	private Image image;
	private long makeTime, currentTime;
	private final int liveTime = 500;
	private boolean isLive;

	public int getX() {
		return x;
	}

	public void setX(int x) {
		this.x = x;
	}

	public int getY() {
		return y;
	}

	public void setY(int y) {
		this.y = y;
	}
	
	public boolean isLive() {
		return isLive;
	}

	public Crash(Image image, int x, int y){
		this.image = image;
		this.x = x;
		this.y = y;
		
		isLive = true;
		makeTime = System.currentTimeMillis();
		
		Thread thread = new Thread(this);
		thread.start();
	}
	
	public void draw(Graphics g){
		g.drawImage(image, x, y, null);
	}

	@Override
	public void run() {
		while(isLive){
			currentTime = System.currentTimeMillis();
			if(currentTime - makeTime > 500)
				isLive = false;
		}
		
	}
	
	
	

}
